home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / fsstat / RCS / print.c,v < prev    next >
Encoding:
Text File  |  1992-04-10  |  29.2 KB  |  941 lines

  1. head     1.6;
  2. branch   ;
  3. access   ;
  4. symbols  sprited:1.6.1;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.6
  10. date     90.02.16.11.40.31;  author jhh;  state Exp;
  11. branches 1.6.1.1;
  12. next     1.5;
  13.  
  14. 1.5
  15. date     89.10.19.12.10.42;  author brent;  state Exp;
  16. branches ;
  17. next     1.4;
  18.  
  19. 1.4
  20. date     89.08.29.15.11.30;  author jhh;  state Exp;
  21. branches ;
  22. next     1.3;
  23.  
  24. 1.3
  25. date     89.06.15.17.42.38;  author brent;  state Exp;
  26. branches ;
  27. next     1.2;
  28.  
  29. 1.2
  30. date     89.02.06.18.40.13;  author brent;  state Exp;
  31. branches ;
  32. next     1.1;
  33.  
  34. 1.1
  35. date     88.12.02.09.06.06;  author brent;  state Exp;
  36. branches ;
  37. next     ;
  38.  
  39. 1.6.1.1
  40. date     92.04.10.16.16.55;  author kupfer;  state Exp;
  41. branches ;
  42. next     ;
  43.  
  44.  
  45. desc
  46. @Print utilities
  47. @
  48.  
  49.  
  50. 1.6
  51. log
  52. @multiple processors
  53. @
  54. text
  55. @/*
  56.  * print.c --
  57.  *    Routines to print out program execution times, and filesystem stats.
  58.  */
  59.  
  60. #include "sprite.h"
  61. #include "status.h"
  62. #include "stdio.h"
  63. #include "proc.h"
  64. #include "vm.h"
  65. #include "spriteTime.h"
  66. #include "sysStats.h"
  67. #include "kernel/fs.h"
  68. #include "kernel/fsStat.h"
  69. #include "kernel/sched.h"
  70. #include "kernel/vm.h"
  71.  
  72.  
  73. /*
  74.  *----------------------------------------------------------------------
  75.  *
  76.  * PrintTimes --
  77.  *
  78.  *    Print the resource usage (user and kernel CPU time) and elapsed time.
  79.  *
  80.  * Results:
  81.  *    None.
  82.  *
  83.  * Side effects:
  84.  *    Prints to the specified stream
  85.  *
  86.  *----------------------------------------------------------------------
  87.  */
  88. void
  89. PrintTimes(stream, usagePtr, timePtr)
  90.     FILE *stream;
  91.     Proc_ResUsage *usagePtr;
  92.     Time *timePtr;
  93. {
  94.     Time delta;
  95.     if (usagePtr != NULL) {
  96.     Time_Add(usagePtr->userCpuUsage, usagePtr->childUserCpuUsage,
  97.                      &delta);
  98.     fprintf(stream, "%d.%03du ", delta.seconds,
  99.                    delta.microseconds / 1000);
  100.     Time_Add(usagePtr->kernelCpuUsage, usagePtr->childKernelCpuUsage,
  101.                      &delta);
  102.     fprintf(stream, "%d.%03ds ", delta.seconds,
  103.                    delta.microseconds / 1000);
  104.     }
  105.     if (timePtr != NULL) {
  106.     int seconds = timePtr->seconds;
  107.     if (seconds >= 3600) {
  108.         fprintf(stream, "%d:", seconds / 3600);
  109.         seconds = seconds % 3600;
  110.     }
  111.     if (seconds >= 60) {
  112.         fprintf(stream, "%d:", seconds / 60);
  113.         seconds = seconds % 60;
  114.     }
  115.     fprintf(stream, "%d.%03d", seconds,
  116.                    timePtr->microseconds / 1000);
  117.     }
  118.     fprintf(stream, "\n");
  119. }
  120.  
  121.  
  122. /*
  123.  *----------------------------------------------------------------------
  124.  *
  125.  * PrintIdleTime --
  126.  *
  127.  *    Given two samples sched module statistics, this computes
  128.  *    the differenc in idle ticks and, using the time, computes
  129.  *    a utilization.
  130.  *
  131.  * Results:
  132.  *    None.
  133.  *
  134.  * Side effects:
  135.  *    Prints to the specified stream
  136.  *
  137.  *----------------------------------------------------------------------
  138.  */
  139. void
  140. PrintIdleTime(stream, startSchedPtr, endSchedPtr, timePtr)
  141.     FILE *stream;
  142.     Sched_Instrument *startSchedPtr, *endSchedPtr;
  143.     Time *timePtr;
  144. {
  145.     register         highTicks;
  146.     double         lowTicks;
  147.     Sys_MachineInfo    machineInfo;
  148.     int            numProcessors;
  149.     ReturnStatus    status;
  150.     int            i;
  151.     int            totalIdleTicksPerSecond;
  152.     double        totalLowTicks;
  153.     int            totalCS;
  154.     int            totalInvCS;
  155.     int            totalFullCS;
  156.     int            diffCS;
  157.     int            diffInvCS;
  158.     int            diffFullCS;
  159.  
  160.     Sched_Instrument zeroStats;
  161.     if (startSchedPtr == NULL) {
  162.     bzero(&zeroStats, sizeof(Sched_Instrument));
  163.     startSchedPtr = &zeroStats;
  164.     }
  165.     status = Sys_GetMachineInfo(sizeof(Sys_MachineInfo), &machineInfo);
  166.     if (status != SUCCESS) {
  167.     printf("Sys_GetMachineInfo returned 0x%x.\n", status);
  168.     exit(status);
  169.     }
  170.     numProcessors = machineInfo.processors;
  171.     totalLowTicks = 0;
  172.     totalIdleTicksPerSecond = 0;
  173.     totalCS = 0;
  174.     totalInvCS = 0;
  175.     totalFullCS = 0;
  176.     for (i = 0; i < numProcessors; i++) {
  177.     if (numProcessors != 1) {
  178.         fprintf(stream, "<%2d> ", i);
  179.     }
  180.     highTicks = endSchedPtr->processor[i].idleTicksOverflow -
  181.             startSchedPtr->processor[i].idleTicksOverflow;
  182.     lowTicks = endSchedPtr->processor[i].idleTicksLow -
  183.             startSchedPtr->processor[i].idleTicksLow;
  184.     
  185.     if (highTicks != 0) {
  186.         fprintf(stream, "(High ticks = %d)", highTicks);
  187.     }
  188.     if (timePtr->seconds == 0 && timePtr->microseconds == 0) {
  189.         fprintf(stream, "Idle ticks --/-- = 100%% Idle, ");
  190.     } else {
  191.         lowTicks /= (double)timePtr->seconds + 
  192.         (double) (timePtr->microseconds)/1000000.;
  193.         totalLowTicks += lowTicks;
  194.         totalIdleTicksPerSecond += 
  195.         endSchedPtr->processor[i].idleTicksPerSecond;
  196.         diffCS = endSchedPtr->processor[i].numContextSwitches - 
  197.             startSchedPtr->processor[i].numContextSwitches;
  198.         totalCS += diffCS;
  199.         diffInvCS = endSchedPtr->processor[i].numInvoluntarySwitches - 
  200.         startSchedPtr->processor[i].numInvoluntarySwitches;
  201.         totalInvCS += diffInvCS;
  202.         diffFullCS = endSchedPtr->processor[i].numFullCS - 
  203.         startSchedPtr->processor[i].numFullCS;
  204.         totalFullCS + diffFullCS;
  205.         fprintf(stream, 
  206.         "Idle ticks %0.0f/%d = %6.2f%% Idle, Context Sw. %d inv %d full %d,",           lowTicks,
  207.            endSchedPtr->processor[i].idleTicksPerSecond,
  208.            (double)lowTicks/
  209.            (double)endSchedPtr->processor[i].idleTicksPerSecond * 100.,
  210.            diffCS, diffInvCS, diffFullCS);
  211.     }
  212.        if (numProcessors == 1) {
  213.        fprintf(stream," Elapsed time ");
  214.         PrintTimes(stream, (Proc_ResUsage *)0, timePtr);
  215.     } else {
  216.         fprintf(stream, "\n");
  217.     }
  218.     }
  219.     if (numProcessors != 1) {
  220.     fprintf(stream,
  221.     "Total: Idle ticks %0.0f/%d = %6.2f%% Idle, Context Sw. %d inv %d full %d, Elapsed time ",
  222.     totalLowTicks, totalIdleTicksPerSecond, 
  223.     totalLowTicks / (double) totalIdleTicksPerSecond * 100.0,
  224.     totalCS, totalInvCS, totalFullCS);
  225.     PrintTimes(stream, (Proc_ResUsage *)0, timePtr);
  226.     }
  227. }
  228.  
  229.  
  230. /*
  231.  *----------------------------------------------------------------------
  232.  *
  233.  * PrintFs_Stats --
  234.  *
  235.  *    Print out the filesystem statistics.  If both a start and end
  236.  *    sample of the statistics are given then the differences between
  237.  *    the two are printed.  To just print the total cumulative statistics
  238.  *    from one sample, specify a single Fs_Stats buffer with the 'end'
  239.  *    parameter.
  240.  *
  241.  * Results:
  242.  *    None.
  243.  *
  244.  * Side effects:
  245.  *    Prints to the specified stream
  246.  *
  247.  *----------------------------------------------------------------------
  248.  */
  249. void
  250. PrintFs_Stats(stream, start, end, verbose)
  251.     FILE *stream;    /* Output stream */
  252.     Fs_Stats *start;    /* 0, or address of "before run" statistics */
  253.     Fs_Stats *end;    /* End of run statistics */
  254.     int verbose;    /* If true, everything is dumped */
  255. {
  256.     register int t1, t2, t3, t4, t5;
  257.     Fs_Stats zeroStats;
  258.  
  259.     if (start == (Fs_Stats *)0) {
  260.     bzero(&zeroStats, sizeof(Fs_Stats));
  261.     start = &zeroStats;
  262.     }
  263.     /*
  264.      * Print cache size
  265.      */
  266.     fprintf(stream, "Cache blocks max %d min %d number %d/%d free %d/%d limit %d\n",
  267.                end->blockCache.maxCacheBlocks,
  268.                end->blockCache.minCacheBlocks,
  269.                start->blockCache.numCacheBlocks,
  270.                end->blockCache.numCacheBlocks,
  271.                start->blockCache.numFreeBlocks,
  272.                end->blockCache.numFreeBlocks,
  273.                end->blockCache.maxNumBlocks);
  274.  
  275.     /*
  276.      * Print bytes read traffic ratio
  277.      */
  278.     t1 = end->blockCache.bytesRead - start->blockCache.bytesRead;
  279.     t2 = end->blockCache.dirBytesRead - start->blockCache.dirBytesRead;
  280.     t3 = end->gen.remoteBytesRead - start->gen.remoteBytesRead;
  281.     t4 = end->gen.fileBytesRead - start->gen.fileBytesRead;
  282.     t5 = end->gen.physBytesRead - start->gen.physBytesRead;
  283.     fprintf(stream, "Bytes read %d+%d remote %d disk %d+%d",
  284.                t1, t2, t3, t4, t5);
  285.     if (t1 + t2 > 0) {
  286.     fprintf(stream, "\ttraffic ratio %%%d\n",
  287.                (int)((double)(t3+t4+t5)/(double)(t1+t2) * 100.));
  288.     } else {
  289.     fprintf(stream, "\n");
  290.     }
  291.  
  292.     /*
  293.      * Print bytes written traffic ratio
  294.      */
  295.     t1 = end->blockCache.bytesWritten - start->blockCache.bytesWritten +
  296.     (end->blockCache.fileDescWrites - start->blockCache.fileDescWrites +
  297.      end->blockCache.indBlockWrites - start->blockCache.indBlockWrites) *
  298.     FS_BLOCK_SIZE;
  299.     t2 = end->blockCache.dirBytesWritten - start->blockCache.dirBytesWritten;
  300.     t3 = end->gen.remoteBytesWritten - start->gen.remoteBytesWritten;
  301.     t4 = end->gen.fileBytesWritten - start->gen.fileBytesWritten;
  302.     t5 = end->gen.physBytesWritten - start->gen.physBytesWritten;
  303.     fprintf(stream, "Bytes written %d+%d remote %d disk %d+%d",
  304.                t1, t2, t3, t4, t5);
  305.     if (t1 + t2 > 0) {
  306.     fprintf(stream, "\ttraffic ratio %%%d",
  307.                (int)((double)(t3+t4+t5)/(double)(t1+t2) * 100.));
  308.     }
  309.     fprintf(stream, "\n");
  310.  
  311.     if (verbose) {
  312.     /*
  313.      * Print device bytes and zero fills
  314.      */
  315.     t1 = end->gen.deviceBytesWritten - start->gen.deviceBytesWritten;
  316.     t2 = end->gen.deviceBytesRead - start->gen.deviceBytesRead;
  317.     fprintf(stream, "Dev bytes read %d written %d\n", t1, t2);
  318.     t1 = end->blockCache.readZeroFills - start->blockCache.readZeroFills;
  319.     t2 = end->blockCache.writeZeroFills1 -
  320.         start->blockCache.writeZeroFills1;
  321.     t3 = end->blockCache.writeZeroFills2 -
  322.         start->blockCache.writeZeroFills2;
  323.     t4 = end->blockCache.fragZeroFills - start->blockCache.fragZeroFills;
  324.     fprintf(stream, "Zero Fills read %d write1 %d write2 %d frag %d\n",
  325.                    t1, t2, t3, t4);
  326.     t1 = end->blockCache.appendWrites - start->blockCache.appendWrites;
  327.     t2 = end->blockCache.overWrites - start->blockCache.overWrites;
  328.     t3 = end->blockCache.domainReadFails -
  329.         start->blockCache.domainReadFails;
  330.     fprintf(stream, "Appends %d Overwrites %d Failed Reads %d\n",
  331.                    t1, t2, t3);
  332.     }
  333.     t1 = end->blockCache.readAccesses - start->blockCache.readAccesses +
  334.      end->blockCache.fragAccesses - start->blockCache.fragAccesses +
  335.      end->blockCache.fileDescReads - start->blockCache.fileDescReads +
  336.      end->blockCache.indBlockAccesses - start->blockCache.indBlockAccesses +
  337.      end->blockCache.dirBlockAccesses - start->blockCache.dirBlockAccesses;
  338.     t2 = end->blockCache.readHitsOnDirtyBlock -
  339.     start->blockCache.readHitsOnDirtyBlock;
  340.     t3 = end->blockCache.readHitsOnCleanBlock -
  341.     start->blockCache.readHitsOnCleanBlock;
  342.     t4 = end->blockCache.fragHits - start->blockCache.fragHits +
  343.      end->blockCache.fileDescReadHits - start->blockCache.fileDescReadHits +
  344.      end->blockCache.indBlockHits - start->blockCache.indBlockHits +
  345.      end->blockCache.dirBlockHits - start->blockCache.dirBlockHits;
  346.     fprintf(stream, "Cache reads %d hits: dirty %d clean %d other %d",
  347.                t1, t2, t3, t4);
  348.     if (t1 != 0) {
  349.     fprintf(stream, "\thit ratio %%%d",
  350.                (int)((double)(t2+t3+t4)/(double)t1 * 100.));
  351.     }
  352.     fprintf(stream, "\n");
  353.  
  354.     t1 = end->blockCache.readAheads - start->blockCache.readAheads;
  355.     t2 = end->blockCache.readAheadHits - start->blockCache.readAheadHits;
  356.     t3 = end->blockCache.allInCacheCalls - start->blockCache.allInCacheCalls;
  357.     t4 = end->blockCache.allInCacheTrue - start->blockCache.allInCacheTrue;
  358.     if (t1 > 0) {
  359.     fprintf(stream, "Read Ahead: hits %d/%d all-in-cache %d/%d\n",
  360.             t2, t1, t4, t3);
  361.     }
  362.  
  363.     t1 = end->blockCache.writeAccesses - start->blockCache.writeAccesses +
  364.      end->blockCache.fileDescWrites - start->blockCache.fileDescWrites +
  365.      end->blockCache.indBlockWrites - start->blockCache.indBlockWrites +
  366.      end->blockCache.dirBlockWrites - start->blockCache.dirBlockWrites;
  367.     t2 = end->blockCache.partialWriteHits - start->blockCache.partialWriteHits +
  368.     end->blockCache.fileDescWriteHits - start->blockCache.fileDescWriteHits;
  369.     t3 = end->blockCache.partialWriteMisses -
  370.     start->blockCache.partialWriteMisses;
  371.     t4 = end->blockCache.blocksWrittenThru -
  372.     start->blockCache.blocksWrittenThru;
  373.     fprintf(stream, "Cache writes %d hits %d misses %d thru %d",
  374.                t1, t2, t3, t4);
  375.     if (t1 != 0) {
  376.     fprintf(stream, "\ttraffic ratio %%%d",
  377.                (int)((double)(t3+t4)/(double)t1 * 100.));
  378.     }
  379.     fprintf(stream, "\n");
  380.     
  381.     fprintf(stream, "Write thru %d data %d indirect %d desc %d dir %d\n",
  382.                t4,
  383.                end->blockCache.dataBlocksWrittenThru -
  384.                start->blockCache.dataBlocksWrittenThru,
  385.                end->blockCache.indBlocksWrittenThru -
  386.                start->blockCache.indBlocksWrittenThru,
  387.                end->blockCache.descBlocksWrittenThru -
  388.                start->blockCache.descBlocksWrittenThru,
  389.                end->blockCache.dirBlocksWrittenThru -
  390.                start->blockCache.dirBlocksWrittenThru);
  391.     if (end->blockCache.fileDescReads > 0) {
  392.     fprintf(stream, "File descriptor reads %d hits %d writes %d hits %d\n",
  393.                    end->blockCache.fileDescReads -
  394.                    start->blockCache.fileDescReads,
  395.                    end->blockCache.fileDescReadHits -
  396.                    start->blockCache.fileDescReadHits,
  397.                    end->blockCache.fileDescWrites -
  398.                    start->blockCache.fileDescWrites,
  399.                    end->blockCache.fileDescWriteHits -
  400.                    start->blockCache.fileDescWriteHits);
  401.     }
  402.     if (end->blockCache.indBlockAccesses > 0) {
  403.     fprintf(stream, "Indirect block reads %d hits %d writes %d\n",
  404.                end->blockCache.indBlockAccesses -
  405.                start->blockCache.indBlockAccesses,
  406.                end->blockCache.indBlockHits -
  407.                start->blockCache.indBlockHits,
  408.                end->blockCache.indBlockWrites -
  409.                start->blockCache.indBlockWrites);
  410.     }
  411.     if (end->blockCache.dirBlockAccesses > 0) {
  412.     fprintf(stream, "Directory block reads %d hits %d writes %d\n",
  413.                    end->blockCache.dirBlockAccesses -
  414.                    start->blockCache.dirBlockAccesses,
  415.                    end->blockCache.dirBlockHits -
  416.                    start->blockCache.dirBlockHits,
  417.                    end->blockCache.dirBlockWrites -
  418.                    start->blockCache.dirBlockWrites);
  419.     }
  420.     if (end->blockCache.vmRequests > 0) {
  421.     fprintf(stream, "VM requests %d tried %d gave %d\n",
  422.                    end->blockCache.vmRequests -
  423.                    start->blockCache.vmRequests,
  424.                    end->blockCache.triedToGiveToVM -
  425.                    start->blockCache.triedToGiveToVM,
  426.                    end->blockCache.vmGotPage -
  427.                    start->blockCache.vmGotPage);
  428.     }
  429.     fprintf(stream, "Cache blocks created %d, alloc from free %d part %d lru %d\n",
  430.                    end->blockCache.unmapped -
  431.                    start->blockCache.unmapped,
  432.                    end->blockCache.totFree -
  433.                    start->blockCache.totFree,
  434.                    end->blockCache.partFree -
  435.                    start->blockCache.partFree,
  436.                    end->blockCache.lru -
  437.                    start->blockCache.lru);
  438.     if (end->alloc.blocksAllocated > 0) {
  439.     fprintf(stream, "Disk blocks alloc %d free %d search %d/%d hash %d\n",
  440.                    end->alloc.blocksAllocated -
  441.                    start->alloc.blocksAllocated,
  442.                    end->alloc.blocksFreed -
  443.                    start->alloc.blocksFreed,
  444.                    end->alloc.cylsSearched -
  445.                    start->alloc.cylsSearched,
  446.                    end->alloc.cylBitmapSearches -
  447.                    start->alloc.cylBitmapSearches,
  448.                    end->alloc.cylHashes -
  449.                    start->alloc.cylHashes);
  450.     fprintf(stream, "Fragments alloc %d free %d upgrade %d blocks made %d used %d, bad hints %d\n",
  451.                    end->alloc.fragsAllocated -
  452.                    start->alloc.fragsAllocated,
  453.                    end->alloc.fragsFreed -
  454.                    start->alloc.fragsFreed,
  455.                    end->alloc.fragUpgrades -
  456.                    start->alloc.fragUpgrades,
  457.                    end->alloc.fragToBlock -
  458.                    start->alloc.fragToBlock,
  459.                    end->alloc.fullBlockFrags -
  460.                    start->alloc.fullBlockFrags,
  461.                    end->alloc.badFragList -
  462.                    start->alloc.badFragList);
  463.     }
  464.     if (end->nameCache.accesses > 0) {
  465.     fprintf(stream, "Name cache entries %d accesses %d hits %d replaced %d\n",
  466.                end->nameCache.size,
  467.                end->nameCache.accesses -
  468.                start->nameCache.accesses,
  469.                end->nameCache.hits -
  470.                start->nameCache.hits,
  471.                end->nameCache.replacements -
  472.                start->nameCache.replacements);
  473.     }
  474.     fprintf(stream, "Handles %d created %d installed %d hits %d old %d version %d flush %d\n",
  475.                end->handle.exists,
  476.                end->handle.created -
  477.                start->handle.created,
  478.                end->handle.installCalls -
  479.                start->handle.installCalls,
  480.                end->handle.installHits -
  481.                start->handle.installHits,
  482.                0,
  483.                end->handle.versionMismatch -
  484.                start->handle.versionMismatch,
  485.                end->handle.cacheFlushes -
  486.                start->handle.cacheFlushes);
  487.     fprintf(stream, "\tfetched %d hits %d released %d locks %d/%d wait %d\n",
  488.                end->handle.fetchCalls -
  489.                start->handle.fetchCalls,
  490.                end->handle.fetchHits -
  491.                start->handle.fetchHits,
  492.                end->handle.release -
  493.                start->handle.release,
  494.                end->handle.locks -
  495.                start->handle.locks,
  496.                end->handle.locks -
  497.                start->handle.locks,
  498.                end->handle.lockWaits -
  499.                start->handle.lockWaits);
  500.     fprintf(stream, "Segments fetched %d hits %d\n",
  501.                end->handle.segmentFetches -
  502.                start->handle.segmentFetches,
  503.                end->handle.segmentHits -
  504.                start->handle.segmentHits);
  505.     fprintf(stream, "Lookup relative %d absolute %d redirect %d found %d loops %d timeouts %d stale %d\n",
  506.                end->prefix.relative -
  507.                start->prefix.relative,
  508.                end->prefix.absolute -
  509.                start->prefix.absolute,
  510.                end->prefix.redirects -
  511.                start->prefix.redirects,
  512.                end->prefix.found -
  513.                start->prefix.found,
  514.                end->prefix.loops -
  515.                start->prefix.loops,
  516.                end->prefix.timeouts -
  517.                start->prefix.timeouts,
  518.                end->prefix.stale -
  519.                start->prefix.stale);
  520. }
  521.  
  522.  
  523. /*
  524.  *----------------------------------------------------------------------
  525.  *
  526.  * PrintDiskStats --
  527.  *
  528.  *    Print out statistics for the disks.  If both a start and end
  529.  *    sample of the statistics are given then the differences between
  530.  *    the two are printed.  To just print the total cumulative statistics
  531.  *    from one sample, specify a single VmStats buffer with the 'end'
  532.  *    parameter.
  533.  *
  534.  * Results:
  535.  *    None.
  536.  *
  537.  * Side effects:
  538.  *    Prints to the specified stream
  539.  *
  540.  *----------------------------------------------------------------------
  541.  */
  542. void
  543. PrintDiskStats(stream, start, end)
  544.     FILE         *stream;/* Output stream */
  545.     Sys_DiskStats    *start;    /* 0, or address of "before run" statistics */
  546.     Sys_DiskStats    *end;    /* End of run statistics */
  547. {
  548.     int    i = 0;
  549.     while (1) {
  550.     if (end[i].name[0] == 0) {
  551.         return;
  552.     }
  553.     if (start == 0) {
  554.         fprintf(stream, "Disk (%s, %d): %0.2f%% Idle Reads %d Writes %d\n",
  555.             end[i].name, end[i].controllerID,
  556.             100 * ((float)end[i].idleCount / (float)end[i].numSamples),
  557.             end[i].diskReads, end[i].diskWrites);
  558.     } else {
  559.         fprintf(stream, "Disk (%s, %d) %0.0f%% Idle Reads %d Writes %d\n",
  560.             end[i].name, end[i].controllerID,
  561.             100 * ((float)(end[i].idleCount - start[i].idleCount) /
  562.                    (float)(end[i].numSamples - start[i].numSamples)),
  563.             end[i].diskReads - start[i].diskReads,
  564.             end[i].diskWrites - start[i].diskWrites);
  565.     }
  566.     i++;
  567.     }
  568. }
  569.  
  570.  
  571. @
  572.  
  573.  
  574. 1.6.1.1
  575. log
  576. @Initial branch for Sprite server.
  577. @
  578. text
  579. @@
  580.  
  581.  
  582. 1.5
  583. log
  584. @Updated to new fs typedefs
  585. @
  586. text
  587. @d91 14
  588. a104 2
  589.     register     highTicks;
  590.     double     lowTicks;
  591. d111 53
  592. a163 7
  593.     highTicks = endSchedPtr->processor[0].idleTicksOverflow -
  594.         startSchedPtr->processor[0].idleTicksOverflow;
  595.     lowTicks = endSchedPtr->processor[0].idleTicksLow -
  596.         startSchedPtr->processor[0].idleTicksLow;
  597.  
  598.     if (highTicks != 0) {
  599.     fprintf(stream, "(High ticks = %d)", highTicks);
  600. d165 7
  601. a171 12
  602.     if (timePtr->seconds == 0 && timePtr->microseconds == 0) {
  603.     fprintf(stream, "Idle ticks --/-- = 100%% Idle, Elapsed time ");
  604.     } else {
  605.     lowTicks /= 
  606.       (double)timePtr->seconds + (double) (timePtr->microseconds)/1000000.;
  607.     fprintf(stream, "Idle ticks %0.0f/%d = %6.2f%% Idle, Context Sw. %d inv %d full %d, Elapsed time ",
  608.            lowTicks,
  609.            endSchedPtr->processor[0].idleTicksPerSecond,
  610.            (double)lowTicks/(double)endSchedPtr->processor[0].idleTicksPerSecond * 100.,
  611.            endSchedPtr->processor[0].numContextSwitches - startSchedPtr->processor[0].numContextSwitches,
  612.            endSchedPtr->processor[0].numInvoluntarySwitches - startSchedPtr->processor[0].numInvoluntarySwitches,
  613.            endSchedPtr->processor[0].numFullCS - startSchedPtr->processor[0].numFullCS);
  614. a172 1
  615.     PrintTimes(stream, (Proc_ResUsage *)0, timePtr);
  616. @
  617.  
  618.  
  619. 1.4
  620. log
  621. @Nuked the Vm print routine
  622. @
  623. text
  624. @d127 1
  625. a127 1
  626.  * PrintFsStats --
  627. d132 1
  628. a132 1
  629.  *    from one sample, specify a single FsStats buffer with the 'end'
  630. d144 1
  631. a144 1
  632. PrintFsStats(stream, start, end, verbose)
  633. d146 2
  634. a147 2
  635.     FsStats *start;    /* 0, or address of "before run" statistics */
  636.     FsStats *end;    /* End of run statistics */
  637. d151 1
  638. a151 1
  639.     FsStats zeroStats;
  640. d153 2
  641. a154 2
  642.     if (start == (FsStats *)0) {
  643.     bzero(&zeroStats, sizeof(FsStats));
  644. @
  645.  
  646.  
  647. 1.3
  648. log
  649. @Updated to new Fs_Stats struct
  650. @
  651. text
  652. @a463 42
  653.  
  654. /*
  655.  *----------------------------------------------------------------------
  656.  *
  657.  * PrintVmStats --
  658.  *
  659.  *    Print out VM statistics.  If both a start and end
  660.  *    sample of the statistics are given then the differences between
  661.  *    the two are printed.  To just print the total cumulative statistics
  662.  *    from one sample, specify a single VmStats buffer with the 'end'
  663.  *    parameter.
  664.  *
  665.  * Results:
  666.  *    None.
  667.  *
  668.  * Side effects:
  669.  *    Prints to the specified stream
  670.  *
  671.  *----------------------------------------------------------------------
  672.  */
  673. void
  674. PrintVmStats(stream, start, end)
  675.     FILE *stream;    /* Output stream */
  676.     Vm_Stat *start;    /* 0, or address of "before run" statistics */
  677.     Vm_Stat *end;    /* End of run statistics */
  678. {
  679.     register    int    *diffPtr;
  680.     register    int    *startPtr;
  681.     register    int    *endPtr;
  682.     int            i;
  683.     int            inusePages;
  684.     int            totPages;
  685.     int            numModifiedPages;
  686.     Vm_Stat        diffStat;
  687.     int            totPercent;
  688.     int            totFaults;
  689.     int            heapPercent;
  690.     int            stkPercent;
  691.     int            quickPercent;    
  692.     int            totHits;
  693.     int            totPrefetches;
  694.     int            hitPct;
  695. a464 186
  696.     startPtr = (int *)start;
  697.     endPtr = (int *)end;
  698.     diffPtr = (int *)&diffStat;
  699.  
  700.     for (i = 0; 
  701.          i < sizeof(Vm_Stat) / sizeof(int); 
  702.      i++, startPtr++, endPtr++, diffPtr++) {
  703.     *diffPtr = *endPtr - *startPtr;
  704.     }
  705.  
  706.     (void)Vm_Cmd(VM_COUNT_DIRTY_PAGES, &numModifiedPages);
  707.     fprintf(stream, "Kernel VM Pages: %d (Code+Data=%d Stacks=%d)\n",
  708.          end->kernMemPages + end->kernStackPages,
  709.          end->kernMemPages, end->kernStackPages);
  710.     inusePages = end->numDirtyPages + end->numUserPages;
  711.     totPages = end->numFreePages + inusePages;
  712.     fprintf(stream, "User VM Pages:   %d (Free=%d Dirty=%d Res=%d Alloc-list=%d)\n",
  713.         end->numFreePages + end->numDirtyPages + 
  714.         end->numReservePages + end->numUserPages, 
  715.         end->numFreePages, end->numDirtyPages,
  716.         end->numReservePages,
  717.         end->numUserPages);
  718.     fprintf(stream, "Modified pages: Total=%d %%Tot-dirty=%0.2f %%Inuse-dirty=%0.2f\n",
  719.         numModifiedPages,
  720.         (float) (numModifiedPages) / (float)totPages * 100.0,
  721.         (float) (numModifiedPages) / (float)inusePages * 100.0);
  722.     fprintf(stream, "FS Pages: Current=%d Max=%d Min=%d\n", 
  723.         end->fsMap - end->fsUnmap, end->maxFSPages, end->minFSPages);
  724.     fprintf(stream,
  725.          "Faults: %8d (Zero=%d FS=%d Swap=%d Quick=%d Coll=%d)\n", 
  726.          diffStat.totalFaults, diffStat.zeroFilled, diffStat.fsFilled,
  727.          diffStat.psFilled,diffStat.quickFaults, diffStat.collFaults);
  728.     fprintf(stream, "        %8d (Code=%d Heap=%d Stack=%d)\n", 
  729.          diffStat.totalFaults, diffStat.codeFaults, diffStat.heapFaults,
  730.          diffStat.stackFaults);
  731.     fprintf(stream, 
  732.         "Mod page stats:  Pot-mod=%d Not-mod=%d Not-hard-mod=%d\n",
  733.         diffStat.potModPages, diffStat.notModPages, 
  734.         diffStat.notHardModPages);
  735.  
  736.     /*
  737.      * Copy on write. 
  738.      */
  739.     totPages = diffStat.numCOWStkPages + diffStat.numCOWHeapPages;
  740.     totFaults = diffStat.numCOWStkFaults + diffStat.numCOWHeapFaults;
  741.     if (diffStat.numCOWHeapPages > 0) {
  742.     heapPercent = 100.0 * ((float)diffStat.numCOWHeapFaults / 
  743.                       diffStat.numCOWHeapPages);
  744.     } else {
  745.     heapPercent = 0;
  746.     }
  747.     if (diffStat.numCOWStkPages > 0) {
  748.     stkPercent = 100.0 * ((float)diffStat.numCOWStkFaults / 
  749.                       diffStat.numCOWStkPages);
  750.     } else {
  751.     stkPercent = 0;
  752.     }
  753.     if (totPages > 0) {
  754.     totPercent = 100.0 * ((float)totFaults / totPages);
  755.     } else {
  756.     totPercent = 0;
  757.     }
  758.     if (totFaults > 0) {
  759.     quickPercent = 100.0 * ((float)diffStat.quickCOWFaults / totFaults);
  760.     } else {
  761.     quickPercent = 0;
  762.     }
  763.     fprintf(stream, 
  764.         "COW: Heap (%d/%d)=%d%% Stk (%d/%d)=%d%% Tot (%d/%d)=%d%%\n",
  765.         diffStat.numCOWHeapFaults, diffStat.numCOWHeapPages, heapPercent,
  766.         diffStat.numCOWStkFaults, diffStat.numCOWStkPages, stkPercent,
  767.         totFaults, totPages, totPercent);
  768.     fprintf(stream, "     Quick (%d/%d)=%d%%\n",
  769.         diffStat.quickCOWFaults, totFaults, quickPercent);
  770.     /*
  771.      * Copy on reference.
  772.      */
  773.     totPages = diffStat.numCORStkPages + diffStat.numCORHeapPages;
  774.     totFaults = diffStat.numCORStkFaults + diffStat.numCORHeapFaults;
  775.     if (diffStat.numCORHeapPages > 0) {
  776.     heapPercent = 100.0 * ((float)diffStat.numCORHeapFaults / 
  777.                       diffStat.numCORHeapPages);
  778.     } else {
  779.     heapPercent = 0;
  780.     }
  781.     if (diffStat.numCORStkPages > 0) {
  782.     stkPercent = 100.0 * ((float)diffStat.numCORStkFaults / 
  783.                       diffStat.numCORStkPages);
  784.     } else {
  785.     stkPercent = 0;
  786.     }
  787.     if (totPages > 0) {
  788.     totPercent = 100.0 * ((float)totFaults / totPages);
  789.     } else {
  790.     totPercent = 0;
  791.     }
  792.     fprintf(stream,
  793.             "COR: Heap (%d/%d)=%d%% Stk (%d/%d)=%d%% Tot (%d/%d)=%d%%\n",
  794.         diffStat.numCORHeapFaults, diffStat.numCORHeapPages, heapPercent,
  795.         diffStat.numCORStkFaults, diffStat.numCORStkPages, stkPercent,
  796.         totFaults, totPages, totPercent);
  797.     totPages = diffStat.numCORStkFaults + diffStat.numCORHeapFaults;
  798.     totFaults = diffStat.numCORCOWStkFaults + diffStat.numCORCOWHeapFaults;
  799.     if (diffStat.numCORCOWHeapFaults > 0) {
  800.     heapPercent = 100.0 * ((float)diffStat.numCORCOWHeapFaults / 
  801.                       diffStat.numCORHeapFaults);
  802.     } else {
  803.     heapPercent = 0;
  804.     }
  805.     if (diffStat.numCORCOWStkFaults > 0) {
  806.     stkPercent = 100.0 * ((float)diffStat.numCORCOWStkFaults / 
  807.                       diffStat.numCORStkFaults);
  808.     } else {
  809.     stkPercent = 0;
  810.     }
  811.     if (totPages > 0) {
  812.     totPercent = 100.0 * ((float)totFaults / totPages);
  813.     } else {
  814.     totPercent = 0;
  815.     }
  816.     fprintf(stream,
  817.             "COR-mod: Heap(%d/%d)=%d%% Stk (%d/%d)=%d%% Tot (%d/%d)=%d%%\n",
  818.         diffStat.numCORCOWHeapFaults, diffStat.numCORHeapFaults,heapPercent,
  819.         diffStat.numCORCOWStkFaults, diffStat.numCORStkFaults, stkPercent,
  820.         diffStat.numCORCOWHeapFaults + diffStat.numCORCOWStkFaults,
  821.         diffStat.numCORHeapFaults + diffStat.numCORStkFaults, totPercent);
  822.  
  823.     fprintf(stream, "Swap pages copied: %d\n", diffStat.swapPagesCopied);
  824.     fprintf(stream,
  825.              "Vm allocs: %d (Free=%d From-FS=%d From-alloc-list=%d)\n",
  826.          diffStat.numAllocs, diffStat.gotFreePage, diffStat.gotPageFromFS, 
  827.          diffStat.pageAllocs);
  828.     fprintf(stream, 
  829.          "VM-FS stats: Asked=%d Free-pages=%d Allocs=%d Frees=%d\n",
  830.          diffStat.fsAsked, diffStat.haveFreePage, diffStat.fsMap, 
  831.          diffStat.fsUnmap);
  832.     fprintf(stream, "Alloc-list searches: %d (Free=%d In-use=%d)\n",
  833.          diffStat.numListSearches, diffStat.usedFreePage, 
  834.          diffStat.numListSearches - diffStat.usedFreePage);
  835.     fprintf(stream, "Extra-searches: %d (Lock=%d Ref=%d Dirty=%d)\n",
  836.          diffStat.lockSearched + diffStat.refSearched + 
  837.          diffStat.dirtySearched,
  838.          diffStat.lockSearched, diffStat.refSearched, 
  839.          diffStat.dirtySearched);
  840.     fprintf(stream, "Pages written %d\n", diffStat.pagesWritten);
  841.  
  842.     totPrefetches = diffStat.codePrefetches + diffStat.heapFSPrefetches +
  843.             diffStat.heapSwapPrefetches + diffStat.stackPrefetches;
  844.     if (totPrefetches > 0) {
  845.     totHits = diffStat.codePrefetchHits + diffStat.heapFSPrefetchHits +
  846.           diffStat.heapSwapPrefetchHits + diffStat.stackPrefetchHits;
  847.     fprintf(stream, "Prefetch stats:\n");
  848.     if (diffStat.codePrefetches > 0) {
  849.         hitPct = 100 * ((float)diffStat.codePrefetchHits / 
  850.                 (float)diffStat.codePrefetches);
  851.         fprintf(stream, "    code (%d/%d)=%d%%\n",
  852.             diffStat.codePrefetchHits, diffStat.codePrefetches, hitPct);
  853.     }
  854.     if (diffStat.heapFSPrefetches > 0) {
  855.         hitPct = 100 * ((float)diffStat.heapFSPrefetchHits / 
  856.                 (float)diffStat.heapFSPrefetches);
  857.         fprintf(stream, "    heap-fs (%d/%d)=%d%%\n",
  858.         diffStat.heapFSPrefetchHits, diffStat.heapFSPrefetches, hitPct);
  859.     }
  860.     if (diffStat.heapSwapPrefetches > 0) {
  861.         hitPct = 100 * ((float)diffStat.heapSwapPrefetchHits / 
  862.                 (float)diffStat.heapSwapPrefetches);
  863.         fprintf(stream, "    heap-swp (%d/%d)=%d%%\n",
  864.         diffStat.heapSwapPrefetchHits, diffStat.heapSwapPrefetches, 
  865.         hitPct);
  866.     }
  867.     if (diffStat.stackPrefetches > 0) {
  868.         hitPct = 100 * ((float)diffStat.stackPrefetchHits / 
  869.                 (float)diffStat.stackPrefetches);
  870.         fprintf(stream, "    stack (%d/%d)=%d%%\n",
  871.         diffStat.stackPrefetchHits, diffStat.stackPrefetches, hitPct);
  872.     }
  873.     hitPct = 100 * ((float)totHits / (float)totPrefetches);
  874.     fprintf(stream, "    total (%d/%d)=%d%%\n",
  875.         totHits, totPrefetches, hitPct);
  876.     fprintf(stream, "    aborts=   %d\n", diffStat.prefetchAborts);
  877.     }
  878.  
  879.     fprintf(stream, "Contexts stolen %d pmegs stolen %d\n",
  880.          diffStat.machDepStat.stealContext, diffStat.machDepStat.stealPmeg);
  881. }
  882. @
  883.  
  884.  
  885. 1.2
  886. log
  887. @Fixed sched_Instrument usage
  888. @
  889. text
  890. @d386 4
  891. a389 4
  892.                end->handle.releaseCalls -
  893.                start->handle.releaseCalls,
  894.                end->handle.lockCalls -
  895.                start->handle.lockCalls,
  896. @
  897.  
  898.  
  899. 1.1
  900. log
  901. @Initial revision
  902. @
  903. text
  904. @a17 1
  905.  
  906. d99 4
  907. a102 3
  908.     highTicks = endSchedPtr->idleTicksOverflow -
  909.         startSchedPtr->idleTicksOverflow;
  910.     lowTicks = endSchedPtr->idleTicksLow - startSchedPtr->idleTicksLow;
  911. d114 5
  912. a118 5
  913.            endSchedPtr->idleTicksPerSecond,
  914.            (double)lowTicks/(double)endSchedPtr->idleTicksPerSecond * 100.,
  915.            endSchedPtr->numContextSwitches - startSchedPtr->numContextSwitches,
  916.            endSchedPtr->numInvoluntarySwitches - startSchedPtr->numInvoluntarySwitches,
  917.            endSchedPtr->numFullCS - startSchedPtr->numFullCS);
  918. a179 1
  919. #ifdef stupid_compiler
  920. a181 3
  921. #else
  922.     fprintf(stream, "\n");
  923. #endif
  924. a198 1
  925. #ifdef stupid_compiler
  926. a202 1
  927. #endif
  928. a241 1
  929. #ifdef stupid_compiler
  930. a245 1
  931. #endif
  932. a268 1
  933. #ifdef stupid_compiler
  934. a272 1
  935. #endif
  936. d376 1
  937. a376 2
  938.                end->handle.oldHandles -
  939.                start->handle.oldHandles,
  940. @
  941.